<?php
/**
 * User: hjd-yao
 * Date: 2019/5/6
 * Time: 14:12
 */

namespace App\Http\Controllers\Backend;


use App\Helpers\SelfResponse;
use App\Http\Controllers\BackendController;
use App\Models\System\ChangeTypeModel;
use Illuminate\Http\Request;

class ChangeTypeController extends BackendController
{
    /**
     * @title 编辑变更类型
     * @param Request $request
     * @param $type_id
     * @return SelfResponse|View
     */
    public function update(Request $request, $type_id)
    {
        $info = ChangeTypeModel::find($type_id);
        if($request->isMethod('post')){
            $info->title = $request->post('title');
            $info->icon = $request->post('icon');
            if($info->save()){
                return SelfResponse::success('编辑成功','b_Config_websiteSet');
            }
            return SelfResponse::error('编辑失败','b_Config_websiteSet');
        }else{
            return view('backend::change.edit',[
                'page_title'=>'编辑变更类型',
                'info'=>$info
            ]);
        }
    }
}